load("//bazel:tachyon.bzl", "if_gpu_is_configured")
load(
    "//bazel:tachyon_cc.bzl",
    "tachyon_cc_library",
    "tachyon_cc_unittest",
    "tachyon_cuda_binary",
)

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "msm_input_provider",
    hdrs = ["msm_input_provider.h"],
    deps = [
        "//tachyon/c/math/elliptic_curves:point_traits_forward",
        "//tachyon/math/geometry:point2",
        "@com_google_absl//absl/numeric:bits",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "msm",
    hdrs = ["msm.h"],
    deps = [
        ":msm_input_provider",
        "//tachyon/base/console",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/math/elliptic_curves/msm:variable_base_msm",
    ],
)

tachyon_cc_library(
    name = "msm_gpu",
    hdrs = ["msm_gpu.h"],
    deps = [
        ":msm_input_provider",
        "//tachyon/base/buffer:vector_buffer",
        "//tachyon/base/console",
        "//tachyon/base/files:file_util",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/device/gpu:gpu_memory",
        "//tachyon/device/gpu:scoped_mem_pool",
        "//tachyon/device/gpu:scoped_stream",
        "//tachyon/math/elliptic_curves/msm:variable_base_msm_gpu",
    ],
)

tachyon_cc_unittest(
    name = "msm_unittests",
    srcs = ["msm_unittest.cc"],
    deps = [
        "//tachyon/base:bits",
        "//tachyon/c/math/elliptic_curves/bn/bn254:g1_test",
        "//tachyon/c/math/elliptic_curves/bn/bn254:msm",
        "//tachyon/math/elliptic_curves/msm/test:variable_base_msm_test_set",
    ],
)

tachyon_cc_unittest(
    name = "msm_gpu_unittests",
    srcs = if_gpu_is_configured(["msm_gpu_unittest.cc"]),
    deps = [
        "//tachyon/base:bits",
        "//tachyon/c/math/elliptic_curves/bn/bn254:msm_gpu",
        "//tachyon/math/elliptic_curves/msm/test:variable_base_msm_test_set",
    ],
)

tachyon_cuda_binary(
    name = "msm_gpu_replay",
    srcs = ["msm_gpu_replay.cc"],
    deps = [
        "//tachyon/base/containers:container_util",
        "//tachyon/base/files:file_path_flag",
        "//tachyon/base/flag:flag_parser",
        "//tachyon/c/math/elliptic_curves/bn/bn254:msm_gpu",
    ],
)
